package com.zzz.product.controller;

/*
 * @author zzr
 * @date: 2025/10/15  17:15
 * @description:
 */

import com.zzz.product.mode.ProductInfo;
import com.zzz.product.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RequestMapping("/product")
@RestController
public class ProductController {
    @Autowired
    private ProductService productService;

    @RequestMapping("/{productId}")
    public ProductInfo getProductById(@PathVariable("productId") Integer productId, String Username) {
        System.out.println("接收到参数" + Username);
        ProductInfo productInfo = productService.selectProductById(productId);
        log.info("收到请求：{}",productId);
        return productInfo;
    }

    @RequestMapping("/p1")
    public String p1(Integer id) {
        return "productService 接收到参数id，id：" + id;
    }

    @RequestMapping("/p2")
    public String p2(Integer id, String name) {
        return "接收到id为：" + id + "name为：" + name;
    }

    @RequestMapping("/p3")
    public String p3(ProductInfo productInfo) {
        return "接收到对象，ProductInfo" + productInfo;
    }

    @RequestMapping("/p4")
    public String p4(@RequestBody ProductInfo productInfo) {
        return "接收到JSON字符串" + productInfo;
    }
}
